var app = new Vue({
    el: '#app',
    data () {
        return {
            errMsg: "",
            userInfo: {
                isFlow: false
            }
        }
    },
    watch: {
        errMsg: function () {
            setTimeout(function () {
                app.errMsg = ''
            }, 2000);
        }
    },
    created () {
        this.getUserInfo()
    },
    methods: {
        // 获取用户信息
        getUserInfo () {
            Axios.post('user/user/userInfo.do', {})
                .then(res => {
                    if (res.respCode === 'S') {
                        localStorage.setItem("userInfo", JSON.stringify(res.data))
                        this.userInfo = res.data
                    }
                })
        },
        // 价格纠错跳转
        priceCorrection () {
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            if (userInfo.isSharer === 'TRUE') {
                window.location.href = "../priceCcorrection/shareAndCorrection.html"
            } else {
                this.errMsg = "您还不是价格分享员，请先去申请成为价格分享员！"
            }
        },
        // 商品上架/核查
        informationSharing () {
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            if (userInfo.isSharer === 'TRUE') {
                window.location.href = "upperShelf.html"
            } else {
                this.errMsg = "您还不是价格分享员，请先去申请成为价格分享员！"
            }
        },
        // 采买任务跳转
        purchasingTask () {
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            if (userInfo.isProcurer === 'TRUE') {
                window.location.href = "../buyTaskList/buyTaskList.html"
            } else {
                this.errMsg = "您还不是采买员，请先去申请成为采买员！"
            }
        },
        // 配送任务跳转
        distributionTask () {
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            if (userInfo.isDeliverer === 'TRUE') {
                window.location.href = "./deliveryTasklist.html?id=0"
            } else {
                this.errMsg = "您还不是配送员，请先去申请成为配送员！"
            }
        },
        //流转中心
        transferCenter () {
            window.location.href = "../transferCenter/transferCenter.html"
        },
        toAuditPrice () {
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            if (userInfo.isProcurer === 'TRUE') {
                window.location.href = "./auditPrice.html"
            } else {
                this.errMsg = "您还不是采买员，请先去申请成为采买员！"
            }
        }
    }
})
